home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1997 #2 / Amiga Plus CD - 1997 - No. 02.iso / system / mui / developer / c / examples / demo.h < prev    next >
C/C++ Source or Header  |  1978-06-11  |  3KB  |  155 lines

  1. /*************************************************************/
  2. /* Includes and other common stuff for the MUI demo programs */
  3. /*************************************************************/
  4.  
  5. /* MUI */
  6. #include <libraries/mui.h>
  7.  
  8. /* System */
  9. #include <dos/dos.h>
  10. #include <graphics/gfxmacros.h>
  11. #include <workbench/workbench.h>
  12.  
  13. /* Prototypes */
  14. #include <clib/alib_protos.h>
  15. #include <clib/exec_protos.h>
  16. #include <clib/dos_protos.h>
  17. #include <clib/icon_protos.h>
  18. #include <clib/graphics_protos.h>
  19. #include <clib/intuition_protos.h>
  20. #include <clib/gadtools_protos.h>
  21. #include <clib/utility_protos.h>
  22. #include <clib/asl_protos.h>
  23.  
  24. #ifndef __GNUC__
  25. #include <clib/muimaster_protos.h>
  26. #else
  27. #include <inline/muimaster.h>
  28. #endif
  29.  
  30. /* ANSI C */
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <stdio.h>
  34.  
  35.  
  36. /* Compiler specific stuff */
  37.  
  38. #ifdef _DCC
  39.  
  40. #define REG(x) __ ## x
  41. #define ASM
  42. #define SAVEDS __geta4
  43.  
  44. #else
  45.  
  46. #define REG(x) register __ ## x
  47.  
  48. #if defined __MAXON__ || defined __GNUC__
  49. #define ASM
  50. #define SAVEDS
  51. #else
  52. #define ASM    __asm
  53. #define SAVEDS __saveds
  54. #endif /* if defined ... */
  55.  
  56.  
  57. #ifdef __SASC
  58. #include <pragmas/exec_sysbase_pragmas.h>
  59. #else
  60. #ifndef __GNUC__
  61. #include <pragmas/exec_pragmas.h>
  62. #endif /* ifndef __GNUC__ */
  63. #endif /* ifdef SASC      */
  64.  
  65. #ifndef __GNUC__
  66.  
  67. #include <pragmas/dos_pragmas.h>
  68. #include <pragmas/icon_pragmas.h>
  69. #include <pragmas/graphics_pragmas.h>
  70. #include <pragmas/intuition_pragmas.h>
  71. #include <pragmas/gadtools_pragmas.h>
  72. #include <pragmas/utility_pragmas.h>
  73. #include <pragmas/asl_pragmas.h>
  74. #include <pragmas/muimaster_pragmas.h>
  75.  
  76. #endif /* ifndef __GNUC__ */
  77.  
  78. extern struct Library *SysBase,*IntuitionBase,*UtilityBase,*GfxBase,*DOSBase,*IconBase;
  79. struct Library *MUIMasterBase;
  80.  
  81. #endif /* ifdef _DCC */
  82.  
  83.  
  84. /*************************/
  85. /* Init & Fail Functions */
  86. /*************************/
  87.  
  88. static VOID fail(APTR app,char *str)
  89. {
  90.         if (app)
  91.                 MUI_DisposeObject(app);
  92.  
  93. #ifndef _DCC
  94.         if (MUIMasterBase)
  95.                 CloseLibrary(MUIMasterBase);
  96. #endif
  97.  
  98.         if (str)
  99.         {
  100.                 puts(str);
  101.                 exit(20);
  102.         }
  103.         exit(0);
  104. }
  105.  
  106.  
  107. #ifdef _DCC
  108.  
  109. int brkfunc(void) { return(0); }
  110.  
  111. int wbmain(struct WBStartup *wb_startup)
  112. {
  113.         extern int main(int argc, char *argv[]);
  114.         return (main(0, (char **)wb_startup));
  115. }
  116.  
  117. #endif
  118.  
  119.  
  120. #ifdef __SASC
  121. int CXBRK(void) { return(0); }
  122. int _CXBRK(void) { return(0); }
  123. void chkabort(void) {}
  124. #endif
  125.  
  126.  
  127. static VOID init(VOID)
  128. {
  129. #ifdef _DCC
  130.         onbreak(brkfunc);
  131. #endif
  132.  
  133. #ifndef _DCC
  134.         if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
  135.                 fail(NULL,"Failed to open "MUIMASTER_NAME".");
  136. #endif
  137. }
  138.  
  139.  
  140. #ifndef __SASC
  141. static VOID stccpy(char *dest,char *source,int len)
  142. {
  143.         strncpy(dest,source,len);
  144.         dest[len-1]='\0';
  145. }
  146. #endif
  147.  
  148.  
  149. #ifndef MAKE_ID
  150. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  151. #endif
  152.  
  153.  
  154. LONG __stack = 8192;
  155.